import { reqUserAddressList, reqOrderInfo } from '@/api'
const state = {
  // 地址信息
  address: [] ,
  tradeInfo : {}

}
const mutations = {
  GETADDRESS(state, address) {
    state.address = address
  },
  SUBMITINFO(state,tradeInfo) {
    state.tradeInfo = tradeInfo
  }
}
const actions = {
  // 获取地址信息
  async getAddress({ commit }) {
    let result = await reqUserAddressList()
    if (result.code == 200) {
      commit('GETADDRESS', result.data)
    } else {
      return Promise.reject(new Error(result.message));
    }
  },
  // 获取商品清单
  async getOrdeInfo({ commit }) {
    let result = await reqOrderInfo()
    if(result.code == 200 ) {
      commit('SUBMITINFO',result.data)
    }
  }
}
const getters = {}

export default {
  state,
  mutations,
  actions,
  getters,
}